package com.example.service.impl;

import com.example.entity.GymInfo;
import com.example.mapper.GymMapper;
import com.example.service.GymService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class GymServiceImpl implements GymService {

    @Autowired
    GymMapper  gymMapper;

    @Override
    public void add(GymInfo gymInfo) {
        gymMapper.insert(gymInfo);
    }

    @Override
    public void deleteById(Integer id) {
        gymMapper.deleteById(id);
    }

    @Override
    public void updateById(GymInfo gymInfo) {
        gymMapper.updateById(gymInfo);
    }

    @Override
    public PageInfo<GymInfo> selectPage(Integer pageNum, Integer pageSize, String gymName, String gymLocation) {
        PageHelper.startPage(pageNum,pageSize);
        List<GymInfo> gymList= gymMapper.selectAll(gymName,gymLocation);
        return PageInfo.of(gymList);
    }


}
